@extends('admin::layouts.master')
@section('title')
    订单列表
@endsection
@section('tab')
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form" >
                    {{csrf_field()}}
                    {{hi_form_hidden('id',$info->id)}}
                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            名称</label>
                        <div class="layui-input-inline" style="width: 225px;">
                            <input type="text" id="username" disabled=""  value="{{$info->name}}" autocomplete="off" class="layui-input"></div>
                    </div>
                    <!-- <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            升级积分</label>
                        <div class="layui-input-inline">
                            <input type="text" id="username"  disabled="" value="{{$info->min_integral}}" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
                    </div> -->

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">升级积分</label>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" disabled="" min="0" value="{{$info->min_integral}}" placeholder="最低积分" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text"  disabled="" value="{{$info->max_integral}}" placeholder="最高积分" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                      <label class="layui-form-label"><span class="x-red">*</span>设置权益</label>
                      <div class="layui-input-block">
                        

                        @foreach($arr_list as $key => $value)
                            <input type="checkbox" name="like1" @if( $value['checked'] ) checked="" @endif value="{{$value['id']}}" lay-skin="primary"  title="{{$value['name']}}" >
                        @endforeach
                      </div>
                  </div>
         


                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="btn_set" data-id="{{$info->id}}" lay-submit="">确认</button>
                    </div>
                </form>
            </div>
        </div>


@endsection

@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
            layer = layui.layer;
           

            //监听提交
            form.on('submit(btn_set)', function (data) {
                var id = $(this).attr('data-id');
                var equities = '';
                $("input:checkbox[name='like1']:checked").each(function(i){
                   equities += ',' + $(this).val();
                });
                $.ajax({
                    url: js_url('admin-grade-update_eqs'),
                    type: 'post',
                    data: {id:id,equities:equities},
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 600, icon: 6}, function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(result.msg, {time: 600, icon: 5});
                        }
                    }
                });
                return false;

            });

        });
    </script>
@endsection